/*
 * Copyright (c) OpenKoala 2011 All Rights Reserved
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.openkoala.koala.dd.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.openkoala.koala.deploy.pojo.Itree;

/**
 * 类    名：DDTree.java
 *   
 * 功能描述：数据字典Tree
 *  
 * 创建日期：2013-2-1上午9:05:37     
 * 
 * 版本信息：
 * 
 * 版权信息：Copyright (c) 2013 Koala All Rights Reserved
 * 
 * 作    者：lingen(lingen.liu@gmail.com)
 * 
 * 修改记录： 
 * 修 改 者    修改日期     文件版本   修改说明	
 */
public class DDTree implements Itree,Serializable {
    
    private static final long serialVersionUID = 9045581107381109803L;

    private String name;
    
    private List<Itree> childrens;
    
    private DDType type;
    
    private DDTree parent;
    
    private List<StaticKeyValue> values;
    
    public static DDTree getStaticDropDDTree(){
        return new DDTree("静态下拉数据",DDType.staticDropDown);
    }
    
    public static DDTree getQueryDropDDTree(){
        return new DDTree("查询下拉数据",DDType.queryDropDown);
    }
    
    public static DDTree getStaticCommonDDTree(String name,DDTree parent){
        return new DDTree(name,DDType.static_common,parent);
    }
    
    public static DDTree getQueryCommonDDTree(String name,DDTree parent){
        return new DDTree(name,DDType.query_common,parent);
    }
    
    /**
     * @param name
     * @param type
     */
    public DDTree(String name, DDType type) {
        super();
        this.name = name;
        this.type = type;
    }
    
    /**
     * @param name
     * @param type
     * @param parent
     */
    public DDTree(String name, DDType type, DDTree parent) {
        super();
        this.name = name;
        this.type = type;
        this.parent = parent;
    }
    
    /**
     * 
     */
    public DDTree() {
        super();
    }

    /*
     *@see org.openkoala.koala.deploy.pojo.Itree#getName()
     */
    @Override
    public String getName() {
        return this.name;
    }

    /*
     *@see org.openkoala.koala.deploy.pojo.Itree#setName(java.lang.String)
     */
    @Override
    public void setName(String name) {
        this.name = name;
    }

    /*
     *@see org.openkoala.koala.deploy.pojo.Itree#setChildren(java.util.List)
     */
    @Override
    public void setChildren(List Children) {
        this.childrens = Children;
    }

    /*
     *@see org.openkoala.koala.deploy.pojo.Itree#getChildren()
     */
    @Override
    public List getChildren() {
        if(childrens==null)childrens = new ArrayList();
        return this.childrens;
    }

    /*
     *@see org.openkoala.koala.deploy.pojo.Itree#isCheck()
     */
    @Override
    public boolean isCheck() {
        throw new UnsupportedOperationException();
    }

    /*
     *@see org.openkoala.koala.deploy.pojo.Itree#setCheck(boolean)
     */
    @Override
    public void setCheck(boolean check) {
        throw new UnsupportedOperationException();
    }

    public DDType getType() {
        return type;
    }

    public void setType(DDType type) {
        this.type = type;
    }

    public DDTree getParent() {
        return parent;
    }

    public void setParent(DDTree parent) {
        this.parent = parent;
    }

    public List<StaticKeyValue> getValues() {
        if(values==null)values = new ArrayList<StaticKeyValue>();
        return values;
    }

    public void setValues(List<StaticKeyValue> values) {
        this.values = values;
    }
    
}
